{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "895050bb",
   "metadata": {},
   "source": [
    "## P67练习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "bf812773",
   "metadata": {},
   "outputs": [],
   "source": [
    "phrase = \"Dont't panic!\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "30d15c0e",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist = list(phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "82ffb8ca",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Dont't panic!\n"
     ]
    }
   ],
   "source": [
    "print(phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "e7a84201",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['D', 'o', 'n', 't', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n"
     ]
    }
   ],
   "source": [
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "d50fde2a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['D', 'o', 'n', 't', \"'\", 't', ' ', 'p', 'a']\n"
     ]
    }
   ],
   "source": [
    "for i in range(4):\n",
    "    plist.pop()\n",
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "153245b9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'D'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plist.pop(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "1fbed437",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist.remove(\"'\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "9bfb2b1d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['o', 'n', 't', ' ', 'p', 'a']\n"
     ]
    }
   ],
   "source": [
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "2a345148",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist.extend([plist.pop(),plist.pop()])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "0585d29f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['o', 'n', 't', ' ', 'a', 'p']\n"
     ]
    }
   ],
   "source": [
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "e2b6d22b",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist.insert(2,plist.pop(3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "0df93610",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['o', 'n', ' ', 't', 'a', 'p']\n"
     ]
    }
   ],
   "source": [
    "print(plist)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "980b28eb",
   "metadata": {},
   "source": [
    "## P81"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "4b614585",
   "metadata": {},
   "outputs": [],
   "source": [
    "phrase = \"Dont't panic!\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0c831372",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist = list(phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "00350475",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Dont't panic!\n"
     ]
    }
   ],
   "source": [
    "print(phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "d9fe0cb5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['o', 'n', ' ', 't', 'a', 'p']\n"
     ]
    }
   ],
   "source": [
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "7e6921f7",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (3078565121.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [30]\u001b[1;36m\u001b[0m\n\u001b[1;33m    new_phrase = ''join(plist[1:3])\u001b[0m\n\u001b[1;37m                   ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "new_phrase = ''join(plist[1:3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "06552fda",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (1015296186.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [31]\u001b[1;36m\u001b[0m\n\u001b[1;33m    new_phrase = new_phrase +  ''join([plist[5],plist[4],plist[7],plist[6]])\u001b[0m\n\u001b[1;37m                                 ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "new_phrase = new_phrase +  ''join([plist[5],plist[4],plist[7],plist[6]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c7ebf1e7",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "b76bdc41",
   "metadata": {},
   "source": [
    "## 列表的总结"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f9de59c8",
   "metadata": {},
   "source": [
    "|  方法   | Description |\n",
    "| :-----------: | :-----------: |\n",
    "| append() | 追加一个元素 |\n",
    "| extend() | 追加多个元素 |\n",
    "| insert() | 在指定索引位置插入元素 |\n",
    "| pop() | 弹出元素并删除 |\n",
    "| remove() | 删除指定对象名字 |\n",
    "| del | 删除列表 |\n",
    "| count() | 查看出现的次数 |\n",
    "| index() | 查看指定元素的索引值 |\n",
    "| sort() |分类排序|\n",
    "|reverse()|将列表进行翻转|\n",
    "|copy()|把前面的列表复制一遍|"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9747112b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
